package com.wxh.producerconsumer.synchronizedcodeblock;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: SynchronizedCodeBlockTest
 * @Description: 同步代码块测试
 * @Author wxh
 * @Date: 2021/12/7 10:18
 * @Version V1.0.0
 * @Since 1.8
 */
public class SynchronizedCodeBlockTest {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>(10);
        // 创建多个线程
        for (int i = 0, len = 4; i < len; i++) {
            Thread t1 = new Thread(new ProducerThread(list));
            t1.setName("生产者线程----" + i + "_");

            Thread t2 = new Thread(new ConsumerThread(list));
            t2.setName("----消费者线程_" + i + "_");

            t1.start();
            t2.start();
        }

    }
}
